<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <table border="1" cellspacing="0" width="300px">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
    
            </tbody>
        </table>
        <script>

            var tbody = document.querySelector('tbody')
            var users = [
                {id:1,name:'dai',age:'18'},
                {id:2,name:'wen',age:'19'},
                {id:3,name:'wen',age:'20'},
                {id:4,name:"ya",age:'21'}
            ]
            users.forEach(function(item){
                var tr = document.createElement("tr");
                for(var key in item){
                    console.log(key)
                    var td = document.createElement("td")
                    td.innerText = item[key];
                    tr.appendChild(td);
                }
                tbody.appendChild(tr)
            })


    </script>
</body>
</html>